"""调整关联删除,自动删除

Revision ID: 3d48e3cc1241
Revises: eee1d892ff88
Create Date: 2025-11-20 13:25:53.456050

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '3d48e3cc1241'
down_revision: Union[str, Sequence[str], None] = 'eee1d892ff88'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(op.f('logs_user_id_fkey'), 'logs', type_='foreignkey')
    op.create_foreign_key(None, 'logs', 'users', ['user_id'], ['id'], ondelete='CASCADE')
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'logs', type_='foreignkey')
    op.create_foreign_key(op.f('logs_user_id_fkey'), 'logs', 'users', ['user_id'], ['id'], ondelete='SET NULL')
    # ### end Alembic commands ###
